package com.yinet.web.controller.touchscreen;

import com.yinet.common.config.Global;
import com.yinet.common.core.controller.BaseController;
import com.yinet.common.core.page.TableDataInfo;
import com.yinet.system.domain.TouchScreenGuidance;
import com.yinet.system.domain.TouchScreenNotice;
import com.yinet.system.service.TouchScreenGuidanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 微信端办事指南
 * z
 *
 * @author yient
 */
@Controller
@RequestMapping("/wx/touchscreen")
public class WXBaseWebController extends BaseController {
    static String touchIndex = "touchscreen/wxweb/";
    @Autowired
    private TouchScreenGuidanceService touchScreenGuidanceService;

    /**
     * 首页列表
     *
     * @return
     */
    @GetMapping(value = "/")
    public String Index(Model model) {
        List<TouchScreenGuidance> guidanceList = touchScreenGuidanceService.selectParentGuidanceList();
        model.addAttribute("guidanceList", guidanceList);
        return touchIndex + "list";
    }

    /**
     * 科室指南视图
     *
     * @return
     */
    @GetMapping(value = "/itemlist/{id}")
    public String ItemList(@PathVariable("id") Long id, Model model) {
        TouchScreenGuidance touchScreenGuidance = touchScreenGuidanceService.selectGuidanceById(id);
        model.addAttribute("guidance", touchScreenGuidance);
        return touchIndex + "itemlist";
    }


    /**
     * 科室指南列表
     *
     * @return
     */
    @PostMapping("/itemlist/{id}")
    @ResponseBody
    public TableDataInfo GetNoticeList(@PathVariable("id") Long id) {
        startPage();
        List<TouchScreenGuidance> guidanceList = touchScreenGuidanceService.selectGuidanceListById(id);
        return getDataTable(guidanceList);
    }

    /**
     * 科室指南列表
     *
     * @return
     */
    @GetMapping("/itemlist/viewDoc/{id}")
    public String viewDoc(@PathVariable("id") Long id, Model model) {
        TouchScreenGuidance touchScreenGuidance = touchScreenGuidanceService.selectGuidanceById(id);
        model.addAttribute("guidance", touchScreenGuidance);
        return touchIndex + "viewdoc";
    }
}
